package com.jackrain.nea.clould.dao;

import com.jackrain.nea.clould.model.CloudErrorModel;
import com.jackrain.nea.clould.model.ONSConsumerMQModel;
import com.jackrain.nea.util.Tools;
import com.jackrain.nea.web.query.QueryEngine;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.sql.Timestamp;

/**
 * 错误日志
 */
@Slf4j
@Component
public class CloudErrorDao {


    public int insert(CloudErrorModel cloudErrorModel) throws Exception {

        if (cloudErrorModel.getId() <= 0) {
            cloudErrorModel.setId(Tools.getInt(com.jackrain.nea.core.db.Tools.getSequence("oms_clouderror"), 0));
        }

        String sql = "insert into oms_clouderror" +
                "(id,ad_client_id,name,errorinfo," +
                "isdute,duteinfo,ip,ptype," +
                "mano,origmsgkey," +
                "ownerid,modifierid,creationdate,modifieddate,isactive)" +
                "values(?,?,?,?," +
                "?,?,?,?," +
                "?,?," +
                "?,?,?,?,?) ";

        Timestamp time = new Timestamp(System.currentTimeMillis());

        int ret = QueryEngine.getInstance().executeUpdate(sql, new Object[]{
                cloudErrorModel.getId(), cloudErrorModel.getAd_client_id(), cloudErrorModel.getName(), cloudErrorModel.getErrorinfo(),
                cloudErrorModel.getIsdute(), cloudErrorModel.getDuteinfo(), cloudErrorModel.getIp(), cloudErrorModel.getPtype(),
                cloudErrorModel.getMano(),cloudErrorModel.getOrigmsgkey(),
                893, 893, time, time, "Y"});


        return ret;

    }



}
